import React, {Component} from "react";
import {
	View,
	Text,
	NetInfo,
} from "react-native";

const NetInfoDecorator = WrappedComponent => class extends Component {
	constructor(props) {
		super(props);
		this.state = {
			isConnected: false,
		}
	}
	componentDidMount() {
		//判断设备是否联网；
		NetInfo.isConnected.addEventListener('change', this._handleNetWorkConnectivityChange);
	}

	_handleNetWorkConnectivityChange = isConnected => this.setState({isConnected})
	render() {
		return (
			<WrappedComponent {...this.props} {...this.state} />
		);
	}
}

export default NetInfoDecorator